| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 2x 2x 2x 2x 10x 10x 2x 2x 2x | const Joi = require('joi');
const mongoose = require('mongoose');
const genreSchema = new mongoose.Schema({
name: {
type: String,
required: true,
minlength: 5,
maxlength: 50
}
});
const Genre = mongoose.model('Genre', genreSchema);
function validateGenre(genre) {
const schema = {
name: Joi.string().min(5).max(50).required()
};
return Joi.validate(genre, schema);
}
exports.genreSchema = genreSchema;
exports.Genre = Genre;
exports.validate = validateGenre; |